#include "wx/wxprec.h"
#include "wx/clntdata.h"

wxClientDataContainer::wxClientDataContainer() {
  m_clientData = NULL;
  m_clientDataType = wxClientData_None;
}

wxClientDataContainer::~wxClientDataContainer() {
  if( m_clientDataType == wxClientData_Object ) {
    delete m_clientObject;
  }
}

void wxClientDataContainer::DoSetClientObject( wxClientData *data ) {
  wxASSERT_MSG( m_clientDataType != wxClientData_Void, wxT( "can't have both object and void client data" ) );
  if( m_clientObject ) {
    delete m_clientObject;
  }
  m_clientObject = data;
  m_clientDataType = wxClientData_Object;
}

wxClientData *wxClientDataContainer::DoGetClientObject() const {
  wxASSERT_MSG( m_clientDataType != wxClientData_Void, wxT( "this window doesn't have object client data" ) );
  return m_clientObject;
}

void wxClientDataContainer::DoSetClientData( void *data ) {
  wxASSERT_MSG( m_clientDataType != wxClientData_Object, wxT( "can't have both object and void client data" ) );
  m_clientData = data;
  m_clientDataType = wxClientData_Void;
}

void *wxClientDataContainer::DoGetClientData() const {
  wxASSERT_MSG( m_clientDataType != wxClientData_Object,
                wxT( "this window doesn't have void client data" ) );
  return m_clientData;
}
